﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DmxInterface {
	
	/// <summary>
	/// Interface for a DMX engine which manages devices and universes.
	/// </summary>
	public interface IEngine : IDisposable {

		/// <summary>Registers a (device, universe) couple which will update the device according to the status of the linked universe.</summary>
		void Register(Device device, Universe universe);

		/// <summary>Deletes the device from the engine and stops sending updates to it.</summary>
		Universe Deregister(Device device);

		/// <summary>Deletes the device from the engine if registered.</summary>
		/// <returns>True if the device has been deregistered.</returns>
		bool TryDeregister(Device device);

		/// <summary>Gets a list of registered devices.</summary>
		/// <remarks>Changes to this list are not tracked and do not change the device-universe coupling.</remarks>
		IList<Device> Devices { get; }

		/// <summary>Starts the engine.</summary>
		/// <remarks>Depending on implementation, this might start output on the registered devices or not.</remarks>
		void Start();

		/// <summary>Stops the engine, updates will not be fed to the registered devices.</summary>
		void Stop();

		/// <summary>Gets or sets the engine's operative frequency.</summary>
		/// <remarks>Effect depends on implementation.</remarks>
		OperativeFrequency Frequency { get; set; }

		/// <summary>Event raised each time some data is sent by the engine.</summary>
		event EventHandler DataSent;

		/// <summary>Event raised just before any data is sent to the device.</summary>
		event EventHandler DataSending;

	}

	public enum OperativeFrequency {
		Recommended,
		High,
		VeryHigh,
		Low,
		VeryLow
	}

}
